import java.util.Scanner;

public class Demo3 {
    private static Object locker=new Object();
    public static void main(String[] args) throws InterruptedException{
        Thread t1=new Thread(()->{
          synchronized (locker){
              System.out.println(" t1 wait之前");
              try {
                  locker.wait();
              } catch (InterruptedException e) {
                  e.printStackTrace();
              }
              System.out.println(" t1 wait之后");
          }
        });
        Thread t2=new Thread(()->{
            System.out.println("t2 notify之前");
            Scanner scanner=new Scanner(System.in);
            scanner.next();  //此处输入任何都行，主要通过这个next构建阻塞
            synchronized (locker){
                locker.notify();
            }
            locker.notify();
            System.out.println("t2 notify之后");
        });
        t1.start();
        t2.start();
    }
}
